from appium import webdriver
from time import sleep
import time , os
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Common():
    def __init__(self):
        os.system('abc root')
        cap ={
            "platformName": "Android",
            "deviceName": "emulator-5554",
            "appPackage": "com.kongfz.app",
            "appActivity": "com.kongfz.app.home.mvvm.homepage.HomeActivity",
            "noReset": True
        }
        self.driver = webdriver.Remote('http//127.0.0.1:4327/wd/hub',cap)
        self.driver.implicitly_wait(25)
        sleep(15)


    def find_ele(self,loc):
        try:
            if type(loc) == str:
                return self.driver.find_element_by_android_uiautomator(loc)
            else:
                return self.driver.find_element(*loc)
        except Exception as e:
            print("报错信息",e)
            print("asdasdsa",loc)